package org.jeecg.modules.demo.crm.service.impl;

import org.checkerframework.checker.units.qual.A;
import org.jeecg.modules.demo.crm.entity.CContract;
import org.jeecg.modules.demo.crm.entity.CWarranty;
import org.jeecg.modules.demo.crm.mapper.CContractMapper;
import org.jeecg.modules.demo.crm.mapper.CProjectApplicationMapper;
import org.jeecg.modules.demo.crm.mapper.CWarrantyMapper;
import org.jeecg.modules.demo.crm.service.ICWarrantyService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;

/**
 * @Description: 质保金记录
 * @Author: jeecg-boot
 * @Date:   2025-07-07
 * @Version: V1.0
 */
@Service
public class CWarrantyServiceImpl extends ServiceImpl<CWarrantyMapper, CWarranty> implements ICWarrantyService {

    @Autowired
    private CProjectApplicationMapper cProjectApplicationMapper;

    @Autowired
    private CContractMapper cContractMapper;

    @Autowired
    private CWarrantyMapper cWarrantyMapper;

    @Override
    public void add(CWarranty cWarranty) {
        CContract cContract = cContractMapper.selectById(cWarranty.getContractId());
        cContract.setWarrantyPrice(cWarranty.getWarrantyPrice());
        cContract.setWarrantyTimeStart(cWarranty.getWarrantyTimeStart());
        cContract.setWarrantyTimeEnd(cWarranty.getWarrantyTimeEnd());
        cContractMapper.updateById(cContract);
        cWarrantyMapper.insert(cWarranty);
    }
}
